"""
@Project: Rebar
@File: settings.py
@Author: hzc
@Date: 2023/3/21 16:18
"""
# ---------------------------- CORS Start ---------------------------------- #
"""
配置CORS
"""
allow_origins = [
    "*"
]

allow_methods = [
    "*"
]

allow_headers = [
    "*"
]

# 跨域是否支持cookies，默认为False。当允许凭证时，allow_origins不能为['*']，必须指定源
credentials = False

# 可以被浏览器访问的响应头，默认为[]
expose_headers = []

# 浏览器缓存CORS相应的最长时间，单位是秒， 默认为600
max_age = 600
# ---------------------------- CORS End ------------------------------ #

# ---------------------------- path start   -------------------------- #
# 静态资源
STATIC_PATH = "./public/"
# 验证码
CODE_PATH = "public/images/code"

# ---------------------------- path End   -------------------------- #


# --------------------------- Token start ------------------------------ #
"""
Token配置信息
"""
# 加密的密钥
SECRET_KEY = "88drd96z5gpiI73bf+rmfldYB9GOyeCElMZnjFyks6Lod2"
# 加密使用的算法
ALGORITHM = "HS256"
ACCESS_TOKEN_EXPIRE_MINUTES = 60  # 访问令牌过期时间(分钟)
ACCESS_TOKEN_REFRESH = 20  # 令牌刷新时间, 当令牌剩余时间小于30分钟就刷新
# --------------------------- Token end ------------------------------ #


# --------------------------- MySQL start ------------------------------ #
"""
MySQL配置信息
"""
# ip
MYSQL_CONFIG = {
    # 数据库账号
    # "USERNAME": "reservoiruser",
    "USERNAME": "root",

    # 数据库密码
    "PASSWORD": "AliyunMysql5188",
    # "PASSWORD": "ly092827",
    # "PASSWORD": "123456",
    # 主机IP
    'HOST': "127.0.0.1",
    # 端口号
    "PORT": 3306,
    # 数据库
    "DATABASE": "reservoir"
}
# --------------------------- MySQL end ------------------------------ #


# --------------------------- Redis start ------------------------------ #
"""
Redis配置信息
"""
REDIS_HOST = '127.0.0.1'  # redis主机IP
# redis存储用户token的键, {}里面存放user_id
SUPER_TOKEN = "redis_SUPER_token-({})"
USER_TOKEN = "redis_USER_token-({})"
EMAIL_TOKEN = "redis_EMAIL_token-({})"
REDIS_CONFIG = {
    'url': f'redis://{REDIS_HOST}',
    'port': 6379,  # redis端口号
    'password': "Redis@rebar#001",  # redis密码
    'db': 0,  # redis数据库
    'encoding': 'utf-8',  # 编码格式
}
# --------------------------- Redis start ------------------------------ #


# ------------------------ Path Setting start  ------------------------- #
"""
路由路径配置
"""
ROUTER_PREFIX = "/api/v1"

PASS_URI = [  # 不需要token校验的路径

    # 根目录
    "/",
    "/download",
    "/favicon.ico",

    # /docs
    "/docs",
    "/openapi.json",

    # 登录
    "/user/login",
    "/user/super_login",
    # 验证码
    "/code/login",
    "/code/email/register",
    "/code/email/password",
    # 未登录进行邮箱验证码校验
    "/user/email/code",
    "/user/email",
    "/user/email/password",
    # 注册
    "/user/register",
    "/user/onlineNum",
    # 公司授权
    "/company/register",
    # 职位列表获取
    "/depart/list"
]
# ------------------------- Path Setting end  --------------------------- #


# ------------------------- User Setting start -------------------------- #
SUPER_ADMIN = "administrator"  # 超级管理员
SUPER_ADMIN_NICKNAME = "系统管理员"
SUPER_ADMIN_PASSWORD = "ADMINISTRATOR"  # 超级管理员密码
SUPER_ADMIN_COMPANY_ID = 0  # 隶属公司
# ------------------------- USER Setting end  --------------------------- #
